<template>
    <div id="delModal">
        <Modal
            v-model="delModal"
            :title="delTitle"
            width="360px;"
            :mask-closable="false"
            :closable="false"
            class-name="delModal"
        >
            <div style="margin: 10px; padding: 16px">{{ delContent }}</div>
            <div slot="footer">
                <el-button
                    @click="handleDelClose"
                    type="info"
                    size="small"
                    plain
                    >取消</el-button
                >
                <el-button
                    @click="handleDelSubmit"
                    type="primary"
                    size="small"
                    plain
                    v-preventReClick="1500"
                    >确定</el-button
                >
            </div>
        </Modal>
    </div>
</template>

<script>
export default {
    name: "delModal",
    props: {
        //删除弹框
        delModal: {
            type: Boolean,
            default: false,
        },
        //删除内容
        delContent: {
            type: String,
            default: "确定要删除这条数据吗？",
        },
        //删除下标
        delIndex: {
            type: Number,
            default: 0,
        },
        //删除标题
        delTitle: {
            type: String,
            default: "删除",
        },
        //删除id
        delId: {
            type: String,
            default: "",
        },
        //删除id
        setDelFn: {
            type: Function,
            default: () => {},
        },
    },
    mounted() {},
    methods: {
        //取消关闭弹窗
        handleDelClose() {
            this.$emit("handleDelClose", false);
        },
        //确定删除
        handleDelSubmit() {
            let params = this.delId;
            this.setDelFn(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.$emit("handleDelSubmit", false);
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => console.log(error));
        },
        setDel(params, setDel) {
            params = JSON.parse(params);
        },
    },
};
</script>

<style scoped lang="scss">
/deep/ .delModal {
    // .ivu-modal-body {
    //     padding: 0 !important;
    // }
}
</style>
